pull: Print elapsed time
authorColin Walters <walters@verbum.org>
Fri, 5 Oct 2012 21:20:40 +0000 (17:20 -0400)
committerColin Walters <walters@verbum.org>
Fri, 5 Oct 2012 21:20:40 +0000 (17:20 -0400)
src/ostree/ostree-pull.c

index a618ee9904bee860558125d662704a5d07e89dc9..765976e98830942e753e5490bcf484d93f1bcc7d 100644 (file)
@@ -1185,6 +1185,8 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
   GKeyFile *remote_config = NULL;
   char **configured_branches = NULL;
   guint64 bytes_transferred;
+  guint64 start_time;
+  guint64 end_time;
 
   memset (pull_data, 0, sizeof (*pull_data));
 
@@ -1214,6 +1216,8 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
       goto out;
     }
 
+  start_time = g_get_monotonic_time ();
+
   pull_data->stdout_is_tty = isatty (1);
 
   pull_data->remote_name = g_strdup (argv[1]);
@@ -1406,6 +1410,8 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
       g_print ("remote %s is now %s\n", remote_ref, checksum);
     }
 
+  end_time = g_get_monotonic_time ();
+
   bytes_transferred = ostree_fetcher_bytes_transferred (pull_data->fetcher);
   if (bytes_transferred > 0)
     {
@@ -1414,10 +1420,11 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
         shift = 1;
       else
         shift = 1024;
-      g_print ("%u metadata, %u content objects fetched; %" G_GUINT64_FORMAT " %s transferred\n", 
+      g_print ("%u metadata, %u content objects fetched; %" G_GUINT64_FORMAT " %s transferred in %u seconds\n", 
                pull_data->n_fetched_metadata, pull_data->n_fetched_content,
                (guint64)(bytes_transferred / shift),
-               shift == 1 ? "B" : "KiB");
+               shift == 1 ? "B" : "KiB",
+               (guint) ((end_time - start_time) / G_USEC_PER_SEC));
     }
 
   ret = TRUE;